using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using TanashCMS.Business;
using NHibernate;

public partial class manager_pages_Create : CMSManagementPageBase
{
    protected void Page_Load(object sender, EventArgs e)
    {
    }

    protected void btnCreatePage_Click(object sender, EventArgs e)
    {
        Response.Redirect("Build.aspx?id=" + CreateStandardWebPage().ToString());
    }

    private int CreateStandardWebPage()
    {
        ISession session = Configuration.GetCurrentSession();
        ITransaction tx = session.BeginTransaction();
        WebPage webpage = null;

        try
        {
            webpage = new WebPage();
            webpage.PageType = WebPageType.Standard;
            webpage.ParentPageID = 0;
            webpage.State = CMSObjectState.Shallow;
            webpage.Website = mWebsite;
            webpage.IsSecure = false;
            session.Save(webpage);
            tx.Commit();
            session.Flush();
            session.Disconnect();
        }
        catch (Exception ex)
        {
            tx.Rollback();
            session.Disconnect();
            throw ex;
        }

        return webpage.ID;
    }
}
